package cn.lonecloud.action.product;


import cn.lonecloud.model.Product;
import cn.lonecloud.service.ProductService;
import cn.lonecloud.service.impl.ProductServiceImpl;
import cn.lonecloud.util.ServletUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 主页面显示物品列表
 *
 * @author lonecloud
 */
@WebServlet("/main")
public class MainServlet extends HttpServlet {

    ProductService productService = new ProductServiceImpl();
    /**
     *
     */
    private static final long serialVersionUID = 2127995402144462373L;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Product> products = productService.showAll();
        req.setAttribute("products", products);
        ServletUtils.forwardUrl(req, resp, "/main.jsp");
    }
}
